package com.dxj.dog.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dxj.dog.admin.domain.DogAdmin;
import com.dxj.dog.admin.service.IDogAdminService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dxj.common.annotation.Log;
import com.dxj.common.core.controller.BaseController;
import com.dxj.common.core.domain.AjaxResult;
import com.dxj.common.enums.BusinessType;

import com.dxj.common.utils.poi.ExcelUtil;
import com.dxj.common.core.page.TableDataInfo;

/**
 * 流浪狗管理Controller
 * 
 * @author 王清江
 * @date 2022-03-27
 */
@RestController
@RequestMapping("/system/dogadmin")
public class DogAdminController extends BaseController
{
    @Autowired
    private IDogAdminService dogAdminService;

    /**
     * 查询流浪狗管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:list')")
    @GetMapping("/list")
    public TableDataInfo list(DogAdmin dogAdmin)
    {
        startPage();
        List<DogAdmin> list = dogAdminService.selectDogAdminList(dogAdmin);
        return getDataTable(list);
    }

    /**
     * 导出流浪狗管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:export')")
    @Log(title = "流浪狗管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DogAdmin dogAdmin)
    {
        List<DogAdmin> list = dogAdminService.selectDogAdminList(dogAdmin);
        ExcelUtil<DogAdmin> util = new ExcelUtil<DogAdmin>(DogAdmin.class);
        util.exportExcel(response, list, "流浪狗管理数据");
    }

    /**
     * 获取流浪狗管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:query')")
    @GetMapping(value = "/{dogId}")
    public AjaxResult getInfo(@PathVariable("dogId") Long dogId)
    {
        return AjaxResult.success(dogAdminService.selectDogAdminByDogId(dogId));
    }

    /**
     * 新增流浪狗管理
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:add')")
    @Log(title = "流浪狗管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DogAdmin dogAdmin)
    {
        return toAjax(dogAdminService.insertDogAdmin(dogAdmin));
    }

    /**
     * 修改流浪狗管理
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:edit')")
    @Log(title = "流浪狗管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DogAdmin dogAdmin)
    {
        return toAjax(dogAdminService.updateDogAdmin(dogAdmin));
    }

    /**
     * 删除流浪狗管理
     */
    @PreAuthorize("@ss.hasPermi('system:dogadmin:remove')")
    @Log(title = "流浪狗管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dogIds}")
    public AjaxResult remove(@PathVariable Long[] dogIds)
    {
        return toAjax(dogAdminService.deleteDogAdminByDogIds(dogIds));
    }

}
